package cn.watson;

import com.netflix.loadbalancer.RandomRule;
import org.hibernate.validator.internal.constraintvalidators.bv.number.bound.AbstractMinValidator;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

/**
 * @Description: order启动类
 * @Author: Zhangrui
 * @Version: 1.0
 * @Date:  2022/7/27 21:54
 */
@SpringBootApplication
@EnableEurekaClient
public class OrderStartApp {

    public static void main(String[] args) {
        SpringApplication.run(OrderStartApp.class,args);
    }

    // 配置一个RestTemplate ，Spring封装的一个机遇Restful风格的http客户端 工具
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

    /**
     * @Title: randomRule
     * @Description: 开启负载均衡，如果要换负载均衡算法修改 RandomRule即可。
     *               此配置方式是全局配置方式
     * @Author: ZhangRui
     * @Version: 1.0
     * @Date:  2022/7/28 11:07
     * @Parameters: []
     * @Return com.netflix.loadbalancer.RandomRule
     */
    @Bean
    public RandomRule randomRule(){
        return new RandomRule();
    }


}
